#include "n32g031.h"
#include "DevicesWatchDog.h"


void vWatchdogInit(void)
{
    /* Enable write access to IWDG_PR and IWDG_RLR registers */
    IWDG_WriteConfig(IWDG_WRITE_ENABLE);

    /* IWDG counter clock: LSI/128 */
    IWDG_SetPrescalerDiv(IWDG_PRESCALER_DIV128);

    /* 40000 / 128 = 312 */
    IWDG_CntReload(312);
    /* Reload IWDG counter */
    IWDG_ReloadKey();

    /* Enable IWDG (the LSI oscillator will be enabled by hardware) */
    IWDG_Enable();
}

void vWatchdogReload(void)
{
    /* Reload IWDG counter */
    IWDG_ReloadKey();
}
